<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Employee extends CI_Controller {

	 public function __construct()
	    {
	        parent::__construct();
	        session_start();
	        //$this->output->enable_profiler(FALSE);
	    	if (!isset($_SESSION['uid']) || $_SESSION['uid'] < 1){
		    	redirect('memberlogin/requiredmessage','refresh');
		    }
		    elseif($_SESSION['role_id'] !=2){
	    		redirect('memberlogin/restriction','refresh');
		    }
            $data['menus'] = 'menus';
            $this->load->vars($data);
	    }
	    
	public function index()
	{
		$data['title'] = "Staff Dashboard - Friends-International Organization";
		$data['main'] = 'staff/dashboard';
		$this->load->vars($data);
		$this->load->view('template'); 
	}
    
    public function profile()
	{
		$data['title'] = "Profile Details View";
		$data['main'] = 'staff/profile';
        $user = $this->MUser->getUser($_SESSION['uid']);
        $id = $user['StaffId'];
		$data['user'] = $this->MStaff->getStaffDetailById($id);	
        $data['documents'] = $this->MStaff->getStaffDocumentByStaffId($id);
        $data['contracts'] = $this->MStaff->getStaffContractByStaffId($id);
        $data['checklist'] = $this->MStaff->getStaffCheckListByStaffId($id);
        $data['form'] = $this->MFormGlobal->getFormEditCancel('/index.php/staffprofile/editstaff/'.$id, '/index.php/staffprofile');
		$this->load->vars($data);
		$this->load->view('template');      
	}
    
    public function payroll()
    {
        $data['title'] = "Payroll View";
		$data['main'] = 'staff/payroll';
        $user = $this->MUser->getUser($_SESSION['uid']);
        $id = $user['StaffId'];
        $datePaid = $this->input->post('datepaid') ? $this->input->post('datepaid') : '';
        $data['payrolls'] = $this->MPayroll->getPayrollByStaffId($id, $datePaid);
		$this->load->vars($data);
		$this->load->view('template');  
    }
    
    public function training()
    {
        $data['title'] = "Training View";
		$data['main'] = 'staff/training';
        $user = $this->MUser->getUser($_SESSION['uid']);
        $id = $user['StaffId'];
        $data['data_rectraining'] = $this->MTraining->getReceiveTrainingByStaffId($id);  
        $data['data_desirabletraining'] = $this->MTraining->getDesirableTrainingByStaffId($id);  
        $data['data_staffskill'] = $this->MTraining->getStaffSkillsByStaffId($id); 
        $data['data_stafffieldvisit'] = $this->MTraining->getStaffFieldVisitByStaffId($id);   
		$this->load->vars($data);
		$this->load->view('template');     
    }
}